package 统计满足K约束的子字符串数量I3258;

public class Solution {
    public int countKConstraintSubstrings(String s, int k) {
        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            int[] arr = new int[2];
            for (int j = i; j < s.length(); j++) {
                if(s.charAt(j) == '0'){
                    arr[0]++;
                }else {
                    arr[1]++;
                }
                if(arr[0] <= k || arr[1] <= k){
                    count++;
                }
            }
        }
        return count;
    }
}
